<?php
	//set picture location off web root ../
	$strDefaultDirectory 	= "./images/product/";
	$strThumbzDirectory		= "./images/product/thumbz/";
	$strLargeDirectory		= "./images/product/large/";
	$strPicture 			= "picture".$_POST[cboPicture];	
	echo "<br />picture ".$strPicture;

	if(!is_uploaded_file($txtUploadedPicture)){
		array_push($ActionResults,"Your Photo Not Attached, Please Try again");
		return(FALSE);
	} 
		
	if (!(substr($txtUploadedPicture_type,0,11)=="image/pjpeg") xor 
		(substr($txtUploadedPicture_type,0,10)=="image/jpeg")){
		array_push($ActionResults,"Picture Upload Failed, Please Supply Picture As JPEG format");
		return(FALSE);
	}
		
	if(!copy($txtUploadedPicture,$strDefaultDirectory."product".$intProductID.$strPicture.".jpg")){
    	array_push($ActionResults,"Failed To Copy $txtUploadedPicture to ".$strDefaultDirectory."product".$intProductID.$strPicture.".jpg");
		return(FALSE);
	}else{
		array_push($ActionResults,"default copied ok");	
	}
		 
	if(!copy($txtUploadedPicture,$strThumbzDirectory."product".$intProductID.$strPicture.".jpg")){
		array_push($ActionResults,"Failed To Copy ".$txtUploadedPicture." to ".$strThumbzDirectory."product".$intProductID.$strPicture.".jpg");
		return(FALSE);
	}else{
		array_push($ActionResults,"thumbnail copied ok");	
	}
		 
	if(PRODUCT_LARGE_PICTURE_WIDTH > 0){
			 
		if(!copy($txtUploadedPicture,$strLargeDirectory."product".$intProductID.$strPicture.".jpg")){
			array_push($ActionResults,"Failed To Copy $txtUploadedPicture $strLargeDirectorypage$intProductID.jpg");
			return(FALSE);
		}else{
			array_push($ActionResults,"large copied ok");
		}
				 
		if(CreateThumbNail($strLargeDirectory,"product".$intProductID.$strPicture.".jpg",PRODUCT_LARGE_PICTURE_WIDTH)){
			array_push($ActionResults,"Resize of ".PRODUCT_LARGE_PICTURE_WIDTH." pixel picture failed");
			return(FALSE);
		}else{
			array_push($ActionResults,"Large resize ok");
		}
	}
			 
	// Shrink copied pictures
	if(CreateThumbNail($strDefaultDirectory,"product".$intProductID.$strPicture.".jpg",PRODUCT_PICTURE_WIDTH)){
		array_push($ActionResults,"Resize of ".PRODUCT_PICTURE_WIDTH." pixel picture failed");
		return(FALSE);
	}else{
		array_push($ActionResults,"default resize ok");
	}
		
	if(CreateThumbNail($strThumbzDirectory,"product".$intProductID.$strPicture.".jpg",PRODUCT_THUMBNAIL_WIDTH)){
		array_push($ActionResults,"Thumbnail Creation Failed");
		return(FALSE);
	}else{
		array_push($ActionResults,"thumbnail resize ok");
	}
			
	unlink($txtUploadedPicture);
	//unset($intProductID);
?>